function [H, G] = cyclgen(n,pol)
  select typeof(pol)
    case 'constant'
      pol = pol(:)';
    case 'polynomial'
      pol = coeff(pol);
  end
    
  n_k = length(pol) - 1;
  k = n - n_k;
  G = [eye(k,k) zeros(k, n_k)];
  
  G = fliplr(G);
  for i = 1:k
    [q r] = gfdeconv(G(i, :), pol, 2);
    G(i, :) = gfadd(G(i, :), r);
  end
  G = fliplr(G);
  
  par = G(:,$-n_k+1:$);
  H = [par' eye(n_k, n_k)];
endfunction

